<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let arr = [2, 3, 1, 1, 4]
        let minOp = 0
        function goFurther(pos) {
            if (pos == 1) {
                minOp++
                return
            }
            let currFurther = pos

            for (let i = pos; i >= 0; i--) {
                if (arr[i] + i >= pos) {
                    currFurther = i
                }
            }
            minOp++
            goFurther(currFurther)
        }
        goFurther(arr.length - 1)
        console.log(minOp)
    </script>
</body>

</html>